import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// vant按需引入插件
import styleImport from 'vite-plugin-style-import';

// 配置1  需要安装 yarn add @types/node    /    npm i -D @types/node
// 如报错：$ vite events.js:352 throw er; // Unhandled 'error' event /  运行 node node_modules/esbuild/install.js
import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  // 配置2
  base: "./",

  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
      "comps": resolve(__dirname, "src/components"),
      "apis": resolve(__dirname, "src/apis"),
      "views": resolve(__dirname, "src/views"),
      "routes": resolve(__dirname, "src/routes"),
      "styles": resolve(__dirname, "src/styles"),

    }
  },
  plugins: [
    vue(),
    styleImport({
      libs: [
        {
          libraryName: 'vant',
          esModule: true,
          resolveStyle: (name) => `vant/es/${name}/style`,
        },
      ],
    }),
  ]
})
